window.onload = function () {
    let ip1 = document.getElementById("ip1");
    let ip2 = document.getElementById("ip2");
    let ip3 = document.getElementById("ip3");
    let ip4 = document.getElementById("ip4");

    // var elementById = document.getElementById("handsome").innerText;
    // alert(elementById);

    axios({
        url: 'https://ip.help.bj.cn/',
        method: 'GET'
    }).then(response => {
        console.log(response.data.data[0]);
        ip1.innerHTML = "你的IP：" + response.data.data[0].ip;
        ip2.innerHTML = "你的位置：" + response.data.data[0].province + response.data.data[0].city + "<br>" + "我去找你玩呀，我的宝！";
        ip3.innerHTML = "<h3>" + response.data.data[0].weather.city + "</h3>" + "天气：" + response.data.data[0].weather.weather
            + "<br>温度：" + response.data.data[0].weather.temp + "<br>风向：" + response.data.data[0].weather.WD
            + "<br>风速：" + response.data.data[0].weather.WS + "<br>PM2.5：" + response.data.data[0].weather.PM25;
        let url = "https:" + response.data.data[0].weather.weathercode;
        ip4.src = url;
    })
}

function goodsentence() {
    let goodsentence = document.getElementById("a1");
    axios({
        url: 'https://api.uixsj.cn/hitokoto/get?type=fart&code=json',
        method: 'GET'
    }).then(response => {
        goodsentence.innerHTML = "<h1>" + response.data.content + "</h1>";
    })
}

function englishMethod() {
    let englishMethod = document.getElementById("a2");
    axios({
        url: 'https://api.uixsj.cn/hitokoto/get?type=en&code=json',
        method: 'GET'
    }).then(response => {
        englishMethod.innerHTML = "<h2>" + response.data.content + "</h2>";
    })
}
